package Animal.com;

public abstract class Animal {
    private String name;

    public Animal(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public abstract void makeSpbund();

}

class Dog extends Animal{
    public Dog(String name){
        super(name);

    }
    @Override
    public void makeSpbund() {
        System.out.println(getName() + "汪汪汪！") ;
    }
}
class Cat extends Animal {
    public Cat(String name){
        super(name);

    }
    @Override
    public void makeSpbund() {
        System.out.println(getName() + "喵喵喵！");
    }
}
class Cow extends Animal{
    public Cow(String name){
        super(name);

    }
    @Override
    public void makeSpbund() {
        System.out.println(getName() + "哞哞哞！");
    }
}

class Zoo {
    private Animal[] animals;
    public Zoo(Animal[] animals){
        this.animals = animals;
    }
    public void makeSpbund(){
        for (int i = 0; i < animals.length; i++) {
            animals[i].makeSpbund();
        }
    }
}
class Test{
    public static void main(String[] args) {
        Animal[] animals = {new Dog("汪汪队立大功！"),new Cat("大橘！"),
        new Cow("大角牛!")};
        Zoo zoo = new Zoo(animals);
        zoo.makeSpbund();
    }
}
